<?php
add_action( 'admin_enqueue_scripts', 'hoanbn_enqueue' );
function hoanbn_enqueue($hook) {
    if( 'index.php' != $hook ) {
		// Only applies to dashboard panel
		return;
    }
    
	wp_enqueue_script( 'ajax-script', plugins_url( '/js/hoanbn_ajax2.js', __FILE__ ), array('jquery') );

	// in javascript, object properties are accessed as ajax_object.ajax_url, ajax_object.we_value
	wp_localize_script( 'ajax-script', 'ajax_object',
            array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'we_value' => 1234 ) );
}

// Same handler function...
add_action( 'wp_ajax_hoanbn_action2', 'hoanbn_action2_callback' );
function hoanbn_action2_callback() {
	global $wpdb;
	$whatever = intval( $_POST['whatever'] );
	$whatever += 20;
        echo "hoanbn".$whatever;
	die();
}
